//
//  QRCodePresentationView.swift
//  Compared with QRCodeView, this view can handle situations where
//  login cookies are not set.
//
//  NJU QR
//
//  Created by 许煜恒 on 8/14.
//

import SwiftUI

struct QRCodePresentationView: View {
    @ObservedObject var result:GetQrResult
    
    var body: some View {
        if result.status == .fetching {
            ProgressView()
        }else if result.status == .successful{
            QRCodeView(qr_content: result.result!)
        }else if result.status == .failed{
            Text("Failed to fetch the contents of the QR Code. ")
        }else if result.status == .unconfigured{
            VStack{
                Text("No log in cookie")
                    .font(.title)
                Text("Click the gear icon below to add one")

            }
        }else{
            Text("Unknown status")
        }
    }
}

struct QRCodePresentationView_Previews: PreviewProvider {
    static var previews: some View {
        QRCodePresentationView(result: getQrContentAsync(login_cookie: ""))
    }
}
